<template>
  <div ref="chart">
  </div>
</template>

<script>
import echarts from 'echarts';
export default {
  name: 'Device',
  data () {
    return {
      chart: '',
      option: {
        title: {
          text: '设备情况',
          x: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b}: {c} ({d}%)'
        },
        legend: {
          orient: 'horizontal',
          top: 'bottom',
          data: ['在线', '离线', '异常']
        },
        color: ['#67C23A', '#E6A23C', '#F56C6C'],
        series: [
          {
            name: '设备情况',
            type: 'pie',
            radius: '55%',
            center: ['50%', '55%'],
            data: [
              {value: 65, name: '在线'},
              {value: 30, name: '离线'},
              {value: 5, name: '异常'}
            ],
            labelLine: {
              length: 10,
              length2: 10
            },
            itemStyle: {
              emphasis: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
    };
  },
  mounted () {
    this.chart = echarts.init(this.$refs['chart']);
    this.chart.setOption(this.option, true);
  }
};
</script>

<style scoped>
  .m-map {
    width: 100%;
    height: 100%;
  }
</style>
